home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_gen / euphor14.zip / STEREO.EX < prev    next >
Text File  |  1995-04-24  |  2KB  |  84 lines

  1. -- Random Dot Stereo Pictures
  2. -- Like the ones you've seen in all the shopping malls!
  3. -- Relax your eyes so that you are focusing a few inches
  4. -- behind the screen - maybe on your reflection if you have
  5. -- a lot of glare. You should see 2 letters of the alphabet,
  6. -- one upper case, one lower case.
  7.  
  8. -- usage:  ex stereo [filename]
  9. -- (will read "picture" by default)
  10.  
  11. -- picture can contain digits from 1 to 9 to indicate "depth"
  12.  
  13. without type_check
  14. include graphics.e
  15.  
  16. constant DEPTH = 13
  17. sequence vc
  18. integer xpixels_per_char, ypixels_per_char, in_file
  19.  
  20. procedure gstereo()
  21.     object input
  22.     sequence image, row, line
  23.     integer index, height, w
  24.     
  25.     image = {}
  26.     while 1 do
  27.     input = gets(in_file)
  28.     if atom(input) then
  29.         exit
  30.     end if
  31.     image = append(image, repeat(' ', DEPTH) & input)
  32.     end while
  33.     w = DEPTH * xpixels_per_char
  34.     for y = 0 to (length(image)-1)*ypixels_per_char do
  35.     line = image[floor(y/ypixels_per_char+1)]
  36.     row = repeat(0, (length(image[1])-1)*xpixels_per_char)
  37.     row[1..w] = rand(repeat(vc[VC_NCOLORS], w))-1
  38.     for x = w + 1 to length(row) do
  39.         height = line[x/xpixels_per_char+1]
  40.         index = x - w
  41.         if height >= '0' then
  42.         if height <= '9' then
  43.             index = index + (height - '0') * xpixels_per_char
  44.         end if
  45.         end if  
  46.         row[x] = row[index]
  47.     end for
  48.     pixel(row, {0, y})
  49.     end for
  50. end procedure
  51.  
  52. if graphics_mode(18) then
  53.     puts(2, "need VGA graphics\n")
  54.     abort(1)
  55. end if
  56.  
  57. sequence cmd, file_name
  58.  
  59. cmd = command_line()
  60. if length(cmd) >= 3 then
  61.     file_name = cmd[3]
  62. else
  63.     file_name = "picture"
  64. end if
  65.  
  66. in_file = open(file_name, "r")
  67. if in_file = -1 then
  68.     printf(1, "Can't open %s\n", {file_name})
  69.     abort(1)
  70. end if
  71.  
  72. clear_screen()
  73. vc = video_config()
  74. xpixels_per_char = floor(vc[VC_XPIXELS]/80)
  75. ypixels_per_char = floor(vc[VC_YPIXELS]/25)
  76.  
  77. gstereo()
  78.  
  79. while get_key() = -1 do
  80. end while
  81. if graphics_mode(-1) then
  82. end if
  83.  
  84.